package xin.fsqr520.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import xin.fsqr520.project.domain.po.Post;

@Mapper
public interface PostMapper extends BaseMapper<Post> {

    @Update("UPDATE post SET comment_count=comment_count + #{count} " +
            "WHERE post_id = #{postId}")
    public Integer addComment(Long postId, Integer count);

    @Update("UPDATE post SET like_count=like_count + #{count} " +
            "WHERE post_id = #{postId}")
    public Integer addLike(Long postId, Integer count);

    @Select("SELECT SUM(like_count) FROM post WHERE user_id = #{userId}")
    Long getLikeCountByUserId(Long userId);
}
